package com.zhen.tika.demo;

import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;

import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: zhen-desktop
 * Date: 2019/1/9
 * Time: 20:20
 */
public class TikaExtraction {

    public static void main(String[] args) throws IOException, TikaException {
        Tika tika = new Tika();
        File fileDir = new File("chapter2/TikaDemo/files");

        if(!fileDir.exists()){
            System.out.println("文件夹不存在，请检查");
            System.exit(0);
        }
        File[] fileArr = fileDir.listFiles();
        String fileContent;
        for(File f: fileArr){
            fileContent = tika.parseToString(f);
            System.out.println("Extracted Content: " + fileContent);
        }
    }


}
